package com.literature.search.file.service;

import com.literature.search.core.entity.CollectFileRelationship;
import com.literature.search.core.entity.LikeFileRelationship;
import com.literature.search.file.entity.vo.CollectionListVO;
import com.literature.search.file.entity.vo.LikeListVO;

import java.util.List;

public interface LikeAndCollectionService {
    /**
     * 获取点赞状态
     * @param fileId
     * @param likeUserId
     */
    Integer getLikeStatus(String fileId, String likeUserId);

    /**
     * 点赞。状态为1
     * @param fileId
     * @param likeUserId
     */
    boolean like(String fileId, String likeUserId);

    /**
     * 取消点赞。将状态改变为0
     * @param fileId
     * @param likeUserId
     */
    boolean dislike(String fileId, String likeUserId);

    /**
     * 从Redis中删除一条点赞数据
     * @param fileId
     * @param likeUserId
     */
    void deleteLikedFromRedis(String fileId, String likeUserId);

    /**
     * 该内容的点赞数变化Δdelta
     * @param fileId
     */
    void in_decrementLikedCount(String fileId, long delta);

    /**
     * 获取Redis中存储的单个文件点赞数量
     * @return
     */
    Integer getLikedCount(String fileId);

    /**
     * 将redis数据写入数据库
     * @return
     */
    void likeRecord2DB() throws InterruptedException;

    /**
     * 新增喜欢记录到数据库
     * @return
     */
    Boolean save(LikeFileRelationship likeFileRelationship);

    /**
     * 从redis获取用户点赞记录
     * @return
     */
    List<LikeFileRelationship> getLikedRecordFromRedis();

    /**
     * 从数据库查询用户点赞记录
     * @return
     */
    List<LikeListVO> queryUserLikeList();

    Integer getCollectedCount(String fileId);

    Integer getCollectStatus(String fileId, String likeUserId);

    boolean collect(String fileId, String userId);

    boolean cancelCollect(String fileId, String likeUserId);

    void deleteCollectdFromRedis(String fileId, String likeUserId);

    void in_decrementCollectedCount(String fileId, long delta);

    void collectRecord2DB() throws InterruptedException;

    Boolean saveCollection(CollectFileRelationship collectFileRelationship);

    List<CollectFileRelationship> getCollectedRecordFromRedis();

    /**
     * 从数据库查询用户收藏记录
     * @return
     */
    List<CollectionListVO> queryUserCollectionList();

    //获取有喜欢记录的FileIds
    List<String> getLikedFileIds();

    //获取有收藏记录的FileIds
    List<String> getCollectdFileIds();
}
